//
//  MYVisitTableViewController.swift
//  MYSinaWeico
//
//  Created by Magic Yu on 16/4/8.
//  Copyright © 2016年 Magic Yu. All rights reserved.
//

import UIKit
//多继承
//OC中有多继承么?如果没有 用什么替换?  协议
//swift必选的协议方法 如果不实现 会报错
class MYVisitTableViewController: UITableViewController,MYVisitorLoginViewDelegate {

    var userLogin = MYUserAccountViewModel.sharedAccountViewModel.userLogin
    //定义一个visitorView的属性 方便外面调用
    var visitorView: MYVisitorLoginView?
    
    override func loadView() {
        userLogin ? super.loadView() : prepareForVisitorLoginView()
    }
    
    private func prepareForVisitorLoginView() {
        
//        let v = MYVisitorLoginView()
//        //        v.backgroundColor = UIColor.redColor()
//        view = v
        
        visitorView = MYVisitorLoginView()
        view = visitorView
        visitorView?.visitorDelegate = self
        
        
        //设置导航条
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录",style: .Plain, target: self, action: "userWillLogin")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册",style: .Plain, target: self, action: "userWillRegister")
        
        
    }
    
    func userWillLogin() {
        print("userWillLogin")
        
        let vc = MYOAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func userWillRegister() {
        print("userWillRegister")
    }
    
   
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
       
    }

 

}
